package xiao.ke.activemq.controller;/**
 * @author XuXiaoK
 * @create 2019-11-27 13:00
 */

import javax.jms.Destination;
import javax.jms.Queue;


import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xiao.ke.activemq.domain.JsonData;
import xiao.ke.activemq.service.ProducerService;


/**
 *@Author XiaoKe
 *@Date 2019/11/27 13:00
 *@Description TODO
 */
@RestController
@RequestMapping("/api/v1")
public class OrderController {

    @Autowired
    private ProducerService producerService;

    @GetMapping("order")
    public Object order(String msg) {
        Destination destination = new ActiveMQQueue("order.queue");
        producerService.sendMessage(destination, msg);
        return JsonData.buildSuccess();
    }

    @GetMapping("common")
    public Object common(String msg) {
        producerService.sendMessage(msg);
        return JsonData.buildSuccess();
    }
}
